﻿@{
    Layout = "~/Views/Shared/_FormWhite.cshtml";
}

<div class="wrapper animated fadeInRight">
    <form id="form" class="form-horizontal m">
        <div class="form-group">
            <label class="col-sm-3 control-label ">开始日期<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="startDate" col="startDate" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">结束日期<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="endDate" col="endDate" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">选择服务项目<font class="red"> *</font></label>
            <div class="col-sm-4">
                <div id="productId" col="ProductId"></div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">选择人员<font class="red"> *</font></label>
            <div class="col-sm-8">
                <div class="col-sm-10" id="userId" col="UserId"></div>
            </div>
        </div>
    </form>
</div>

<script type="text/javascript">
    var id = ys.request("id");
    $(function () {
        $('#form').validate({
            rules: {
                startDate: { required: true },
                endDate: { required: true },
                productId: { required: true },
                userId: { required: true }
            }
        });

        laydate.render({
            elem: '#startDate',
            done: function (value, date, endDate) {
                b.config.min = {
                    year: date.year,
                    month: date.month - 1,
                    date: date.date,
                    hours: date.hours,
                    minutes: date.minutes,
                    seconds: date.seconds
                }
            }
        });
        var b = laydate.render({
            elem: '#endDate',
        });

        $("#productId").ysComboBox({
            url: '@Url.Content("~/ProductManage/Product/GetListJson")',
            key: "Id",
            value: "ProductName",
            class: "form-control",
            onChange: function () {
                $("#userId").ysCheckBox({
                    url: '@Url.Content("~/ProductManage/ProductUser/GetListJson")' + '?ProductId=' + this.value,
                    dataName: "Result",
                    key: "UserId",
                    value: "UserName"
                });
            }
        });
    });

    function saveForm(index) {
        if ($('#form').validate().form()) {
            var postData = $('#form').getWebControls({ Id: id });
            ys.ajax({
                url: '@Url.Content("~/ScheduleManage/ScheduleUser/SaveFormJson")',
                type: 'post',
                data: postData,
                success: function (obj) {
                    if (obj.Tag == 1) {
                        ys.msgSuccess(obj.Message);
                        parent.searchGrid();
                        parent.layer.close(index);
                    }
                    else {
                        ys.msgError(obj.Message);
                    }
                }
            });
        }
    }
</script>

